package com.example.springboot.service.impl;

import com.example.springboot.controller.request.BaseRequest;
import com.example.springboot.entity.Activity;
import com.example.springboot.mapper.ActivityMapper;
import com.example.springboot.service.IActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class ActivityService implements IActivityService {

    @Resource
    ActivityMapper activityMapper;

    //查询所有
    @Override
    public List<Activity> list() {
        return activityMapper.list();
    }

    //分页
    @Override
    public PageInfo<Activity> page(BaseRequest baseRequest) {
        PageHelper.startPage(baseRequest.getPageNum(), baseRequest.getPageSize());
        List<Activity> activitys = activityMapper.listByCondition(baseRequest);
        return new PageInfo<>(activitys);
    }

    //更新
    @Override
    public void update(Activity activity) {
        activityMapper.update(activity);
    }


    //新增
    @Override
    public void save(Activity activity) {
        activityMapper.save(activity);
    }



    @Override
    public Activity getById(Integer id) {
        return activityMapper.getById(id);
    }

    //删除
    @Override
    public void deleteById(Integer id) {
        activityMapper.deleteById(id);
    }



}
